package model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 * <p>
 * Title: Graph</p>
 * <p>
 * Description: CS 343 Project. Stores the data model for the graph
 * properties.</p>
 *
 * @date 11/18/2013
 *
 * @author Dylan Ahmann
 * @author Gregg Roemhildt - Class Programming and Javadocs
 * @author Sam Brockmann - Javadocs
 * @author Emily Hancock
 * @author Shirin Asadi
 *
 *
 * @param <T> Type of data to store in Vertex
 */
//@Entity
public class Graph<T extends Serializable> implements Serializable {

//    private static final long serialVersionUID = 1L;
//    @Id
//    @GeneratedValue(strategy = GenerationType.AUTO)
//    private Long id;
    protected List<Vertex<T>> vertices;
    protected List<Edge<T>> edges;

    /**
     * constructor
     *
     * Initializes the two hash sets, vertices and edges.
     */
    public Graph() {
        vertices = new ArrayList<>();
        edges = new ArrayList<>();
    }

    /**
     * copy constructor
     *
     * @param g graph to perform deep copy on
     */
    public Graph(Graph g) {
        vertices = new ArrayList<>(g.vertices);
        edges = new ArrayList<>(g.edges);
    }

    /**
     * getEdges - getter for the set of edges
     *
     * @return edges
     */
    public List<Edge<T>> getEdges() {
        return edges;
    }

    /**
     * getVerticies - getter for the set of vertices
     *
     * @return vertices
     */
    public List<Vertex<T>> getVertices() {
        return vertices;
    }

    /**
     * addEdge Adds an edge to the graph set edges
     *
     * @param e edge to add
     */
    public void addEdge(Edge<T> e) {
        edges.add(e);

    }

    /**
     * addVertex Adds an edge to the graph.
     *
     * @param v the Vertex to add
     *
     */
    public void addVertex(Vertex<T> v) {
        vertices.add(v);
    }

    /**
     * toString - toString method for Graph class
     *
     * @return text String
     */
    @Override
    public String toString() {
        return "Graph";
    }

//    /**
//     * getId - getter for the id
//     *
//     * @return id
//     */
//    public Long getId() {
//        return id;
//    }

//    /**
//     * setter for the id
//     *
//     * @param id
//     */
//    public void setId(Long id) {
//        this.id = id;
//    }

//    /**
//     * hashCode Generates the hashCode.
//     *
//     * @return hash
//     *
//     */
//    @Override
//    public int hashCode() {
//        int hash = 0;
//        hash += (id != null ? id.hashCode() : 0);
//        return hash;
//    }

//    /**
//     * equals Checks whether graph id is equal.
//     *
//     * @param object a type of object
//     * @return true or false
//     *
//     */
//    @Override
//    public boolean equals(Object object) {
//        //Warning - this method won't work in the case the id fields are not set
//        if (!(object instanceof Graph)) {
//            return false;
//        }
//        Graph other = (Graph) object;
//        return (this.id != null || other.id == null)
//                && (this.id == null || this.id.equals(other.id));
//    }
}
